from appium.webdriver.common.mobileby import MobileBy
from selenium.webdriver.common.by import By

'''
—————————————————————————————————————————————————————————————
启动页面配置信息
_____________________________________________________________
'''
# 3.5.2版本后隐私页面改为隐私弹窗，应用一下元素定位信息，如果运行版本之前的脚本需要换成旧版
# approve = By.ID, 'com.izaodao.gps:id/img_agree'
approve = By.ID, 'com.izaodao.gps:id/tv_yes'
skip_user_desc = By.ID, 'com.izaodao.gps:id/tv_start1'
# APP的相关权限申请弹窗下一步
right_next_step = By.ID, 'com.izaodao.gps:id/qxButtonAccept'
# 3.5.5工信部版本后增加跳转小程序弹窗
jump_wxxcx_tanchuang = By.ID, 'com.izaodao.gps:id/tv_confirm_dialog_goto_btn'
general_tanchuang_close_btn = By.ID,'com.izaodao.gps:id/iv_close'
login_back_no_phone = By.XPATH,'//android.view.View[@content-desc="登录/注册"]/../android.widget.FrameLayout[1]/android.widget.ImageView'
'''
—————————————————————————————————————————————————————————————
五十音页面配置信息
_____________________________________________________________
'''
wsy_tab = By.ID, 'com.izaodao.gps:id/clMainTabHome'
wsy_touxiang = By.ID, 'com.izaodao.gps:id/kana_img'
wsy_jiaming = By.ID, 'com.izaodao.gps:id/kana_tv'
wsy_zixuanfuxi = By.ID, 'com.izaodao.gps:id/home_tv_exam'
wsy_lianliankan = By.ID, 'com.izaodao.gps:id/home_tv_link'
wsy_ad = By.ID, 'com.izaodao.gps:id/img_ads'
'''
—————————————————————————————————————————————————————————————
学习页面学习配置信息
_____________________________________________________________
'''
wsy_start_study = By.ID, 'com.izaodao.gps:id/tvHomeStartLearning'
study_1_xuexi = By.XPATH, "//android.widget.TextView[@text = 'あ']/../../" \
                          "android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.RelativeLayout[1]"
study_1_cover_close = By.XPATH, "//*[@text = '点此按钮开始练习']/../android.widget.ImageView[1]"
study_1_letter = "//*[@text = '']"
# study_1_letter_2 = By.XPATH,"//*[@text = 'い']"
# study_1_letter_3 = By.XPATH,"//*[@text = 'う']"
# study_1_letter_4 = By.XPATH,"//*[@text = 'え']"
# study_1_letter_5 = By.XPATH,"//*[@text = 'お']"
study_1_letter_roma = By.ID, "com.izaodao.gps:id/tv_roma"
study_1_bottom_btn = By.ID, "com.izaodao.gps:id/tvHomeStartLearning"
study_1_play_write = By.ID, "com.izaodao.gps:id/plag_rl"
study_1_write = By.ID, "com.izaodao.gps:id/write_rl"
study_1_clear = By.ID, "com.izaodao.gps:id/img_clean"
study_1_write_area = By.ID, "com.izaodao.gps:id/img_tian"
study_1_bottom_return = By.ID, "com.izaodao.gps:id/img_return"
# study_video = By.ID, "com.izaodao.gps:id/menuActionVideo"
study_video_play = By.ID, "com.izaodao.gps:id/zpvKanaVideoPlayer"
study_video_play_btn = By.ID, "com.izaodao.gps:id/ivPlayBtn"
study_video_play_time = By.ID, "com.izaodao.gps:id/tvTime"
study_viseo_play_full_screen = By.ID, "com.izaodao.gps:id/ivFullScreen"
study_video_frame = By.ID, "com.izaodao.gps:id/gestureMask"

'''
—————————————————————————————————————————————————————————————
学习页面测试配置信息
_____________________________________________________________
'''
study_title1 = By.XPATH, "//	android.widget.TextView[@text = '清音阶段']"
study_title2 = By.XPATH, "//	android.widget.TextView[@text = '浊音阶段']"
study_title3 = By.XPATH, "//	android.widget.TextView[@text = '拗音阶段']"
study_title4 = By.XPATH, "//	android.widget.TextView[@text = '长音·促音·音调']"
study_video = By.ID, 'com.izaodao.gps:id/menuActionVideo'
study_video_download = By.ID, 'com.izaodao.gps:id/ivKanaVideoDownloadIcon'
study_1 = By.XPATH, "//android.widget.TextView[@text = 'あ']"

study_1_ceshi = By.XPATH, "//android.widget.TextView[@text = 'あ']/../../" \
                          "android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.RelativeLayout[2]"
study1_title = By.XPATH, "//android.widget.TextView[@text = '1/20']"
study1_question = By.ID, "com.izaodao.gps:id/tv_stem"
study1_ans = By.ID, "com.izaodao.gps:id/v_1"
study1_confirm = By.ID, 'com.izaodao.gps:id/tv_confirm'
study1_next = By.ID, 'com.izaodao.gps:id/tv_next'
study1_back = By.ID, 'com.izaodao.gps:id/defaultBackButton'
study1_back_confirm = By.ID, 'com.izaodao.gps:id/tv_negative'
study1_back_cancel = By.ID, 'com.izaodao.gps:id/tv_positive'
# study1_share_report = By.ID, 'com.izaodao.gps:id/ 应对80分以上才会有分享成绩单
study1_share_report = By.XPATH, "//*[contains(@text,'测试成绩')]"
study1_score = By.ID, 'com.izaodao.gps:id/tv_questions_score'
study1_question_count = By.ID, 'com.izaodao.gps:id/tv_questions_count'
study1_time = By.ID, 'com.izaodao.gps:id/tv_questions_time'
study1_report_back = By.ID, 'com.izaodao.gps:id/iv_back'
study1_ad = By.ID, 'com.izaodao.gps:id/tv_guide'
study1_wuxingtanchuang_close = By.ID, 'com.izaodao.gps:id/iv_close'
study2_locked = By.XPATH, "//android.widget.TextView[contains(@text , 'か')]/../../android.widget.ImageView"
fuxi_1 = By.XPATH, "//*[@text = 'あ']"
fuxi_1_start = By.ID, "com.izaodao.gps:id/tv_start"
'''
—————————————————————————————————————————————————————————————
发现页面配置信息
_____________________________________________________________
'''
fx_banner = By.ID, 'com.izaodao.gps:id/bvDiscoveryBanner'
fx_daily_word = By.ID, 'com.izaodao.gps:id/tvDiscoveryHeaderDailyTitle'
fx_AI_study = By.ID, 'com.izaodao.gps:id/tvDiscoveryHeaderAiTitle'
'''
—————————————————————————————————————————————————————————————
跟老师学页面配置信息
列表元素定位需要考虑
_____________________________________________________________
'''
glsx_tab = By.ID, 'com.izaodao.gps:id/clMainTabLearn'
glsx_title = By.XPATH, "//android.widget.TextView[@text = '跟老师学']"
glsx_ljzaodao = By.ID, 'com.izaodao.gps:id/tv_understand'
glsx_banner = By.ID, 'com.izaodao.gps:id/img_banner'
glsx_sub_title = By.ID, 'com.izaodao.gps:id/tvDiscoveryTypeCoverTitle'
glsx_list_1 = By.XPATH, "//android.support.v7.widget.RecyclerView[@resource-id= 'com.izaodao.gps:id/rvDiscoveryTypeCoverContent']" \
                        "/android.widget.RelativeLayout[1]"
glsx_qingning = By.XPATH, "//*[contains(@text,'网红老师')]"
glsx_qingning_title = By.ID, 'com.izaodao.gps:id/defaultTitleView'
glsx_qingning_mflq_btn = By.XPATH, "//*[contains(@text, '免费领取')]"
glsx_qingning_jump_to_zdqx = By.ID, 'com.tencent.mm:id/eg'
glsx_qingning_list_btn = By.XPATH, "//*[contains(@text,'网红老师')]/../android.widget.TextView[3]"
glsx_xcxzbk = By.XPATH, "//*[contains(@text,'日语零基础入门直播课')]"
glsx_xcxzbk_mfyy_btn = By.XPATH, "//*[contains(@text, '免费预约')]"
glsx_xcxzbk_jrzb_btn = By.XPATH, "//*[contains(@text, '进入直播')]"
glsx_xcxzbk_list_btn = By.XPATH, "//*[contains(@text,'日语零基础入门直播课')]/../android.widget.TextView[3]"
glsx_zxk_1 = By.XPATH, "//*[contains(@text, '初学者要掌握的日常用语')]"
glsx_zxk_1_list_btn = By.XPATH, "//*[contains(@text,'初学者要掌握的日常用语')]/../android.widget.TextView[3]"
glsx_zxk_2 = By.XPATH, "//*[contains(@text, '月亮老师带你从“食”学日语')]"
glsx_zxk_2_list_btn = By.XPATH, "//*[contains(@text,'月亮老师带你从“食”学日语')]/../android.widget.TextView[3]"
glsx_zxk_list_btn_close = By.ID, 'com.izaodao.gps:id/iv_close'
glsx_zxk_mflq = By.XPATH, "//*[contains(@text, '免费领取')]"
glsx_zxk_lq_success = By.XPATH, "//*[contains(@text, '领取成功')]"
glsx_ffk = By.XPATH, "//*[contains(@text,'解锁50音图记忆与发音')]"
glsx_ffk_en = By.XPATH, "//*[contains(@text,'3天提升英语口语入门课')]"
glsx_ffk_list_btn = By.XPATH, "//*[contains(@text,'解锁50音图记忆与发音')]/../android.widget.TextView[3]"
glsx_ffk_list_btn_en = By.XPATH, "//*[contains(@text,'3天提升英语口语入门课')]/../android.widget.TextView[3]"
glsx_ffk_pay_btn = By.XPATH, "//*[contains(@text, '支 付')]"
glsx_ffk_pay_btn_en = By.XPATH, "//*[contains(@text, '支 付')]"
glsx_ffk_ljgk = By.XPATH, "//*[contains(@text, '立即购课')]"
glsx_ffk_ljgk_en = By.XPATH, "//*[contains(@text, '立即购课')]"
glsx_ad = By.ID, 'com.izaodao.gps:id/img_ads'
glsx_ad_close = By.ID, 'com.izaodao.gps:id/iv_close'
glsx_tanchuang = By.ID, 'com.izaodao.gps:id/img_ads'
glsx_tanchuang_dongtu = By.ID, 'com.izaodao.gps:id/lottieAnimationView'
glsx_tanchuang_close = By.ID, 'com.izaodao.gps:id/iv_close'
glsx_type_default_title = By.ID, 'com.izaodao.gps:id/defaultTitleView'
glsx_type_zxzx_btn = By.XPATH, "//*[contains(@text, '免费领取')]"
glsx_type_ffk_btn = By.XPATH, "//*[contains(@text, '￥1')]"
glsx_wxk = By.XPATH, "//*[contains(@text, '日语零基础入门精品课')]"
glsx_wxk_mflq_btn = By.XPATH, "//*[contains(@text, '免费领取')]"
glsx_wxk_list_btn = By.XPATH, "//*[contains(@text, '日语零基础入门精品课')]/../android.widget.TextView[3]"

glsx_swip_area = By.ID, 'com.izaodao.gps:id/rvCourseList'
glsx_yurenjie = By.XPATH, "//*[contains(@text, '戳我领礼包')]"
glsx_list_swipe_area = By.ID, "com.izaodao.gps:id/rvCourseList"

'''
—————————————————————————————————————————————————————————————
我的页面配置信息
_____________________________________________________________
'''
wd_tab = By.ID, 'com.izaodao.gps:id/clMainTabMe'
wd_tab_hongdian = By.ID, 'com.izaodao.gps:id/iv_my_new'
wd_username = By.XPATH, '//android.widget.TextView[@text = "测试号9001"]'
wd_login = By.ID, 'com.izaodao.gps:id/tvMeUserName'
wd_touxiang = By.ID, 'com.izaodao.gps:id/ivMeAvatar'
wd_daily_task = By.ID, 'com.izaodao.gps:id/tv_daily_mask_text'
wd_daily_task_hongdian = By.ID, 'com.izaodao.gps:id/iv_daily_new'
wd_study_management = By.XPATH, "//android.widget.TextView[@text = '学习管理']"
wd_shop = By.XPATH, "//android.widget.TextView[@text = '积分商城']"
wd_share_app = By.XPATH, "//android.widget.TextView[@text = '分享App给好友']"
wd_share_app_to_QQ = By.ID, "com.izaodao.gps:id/tvShareDialogQQ"
wd_share_app_agree_btn = By.ID, "com.android.permissioncontroller:id/permission_allow_button"
wd_yijianfankui = By.XPATH, "//android.widget.TextView[@text = '意见反馈']"
wd_update_tiku = By.XPATH, "//android.widget.TextView[@text = '更新题库']"
wd_setting = By.ID, 'com.izaodao.gps:id/ivMeSetting'
wd_coin = By.ID, 'com.izaodao.gps:id/tvMeCoinCount'
'''
—————————————————————————————————————————————————————————————
设置页面配置信息
_____________________________________________________________
'''

setting_title = By.ID, 'com.izaodao.gps:id/defaultTitleView'
setting_person = By.ID, 'com.izaodao.gps:id/tvSettingProfile'
setting_notice = By.ID, 'com.izaodao.gps:id/tvSettingNotice'
setting_clear_cache = By.ID, 'com.izaodao.gps:id/clSettingClearCache'
setting_security = By.ID, 'com.izaodao.gps:id/tvSettingSecurity'
setting_about = By.ID, 'com.izaodao.gps:id/tvSettingAbout'
setting_logout = By.ID, 'com.izaodao.gps:id/tvSettingLogout'
setting_logout_confirm = By.ID, 'com.izaodao.gps:id/accept'
setting_back = By.ID, 'com.izaodao.gps:id/defaultBackButton'
'''
—————————————————————————————————————————————————————————————
个人资料页面配置信息
_____________________________________________________________
'''
person_back = By.ID, 'com.izaodao.gps:id/defaultBackButton'
person_title = By.ID, 'com.izaodao.gps:id/defaultTitleView'
person_change_touxiang = By.ID, 'com.izaodao.gps:id/clProfileAvatar'
person_select_touxiang_from_album = By.ID, "com.izaodao.gps:id/tvImageSelectDialogAlbum"
person_select_allow_btn = By.ID, 'com.android.permissioncontroller:id/permission_allow_button'
person_first_img = By.XPATH, "//*[@resource-id ='com.android.documentsui:id/dir_list']/android.widget.LinearLayout[1]"
person_modify_confim = By.ID, 'com.android.gallery3d:id/head_select_right'

person_username = By.ID, 'com.izaodao.gps:id/tvProfileNameText'
person_gender = By.ID, 'com.izaodao.gps:id/tvProfileGenderText'
person_change_touxiang_camera = By.ID, 'com.izaodao.gps:id/tvImageSelectDialogCamera'
person_change_touxiang_album = By.ID, 'com.izaodao.gps:id/tvImageSelectDialogAlbum'
person_change_touxiang_cancel = By.ID, 'com.izaodao.gps:id/tvImageSelectDialogCancel'
person_gender_male = By.ID, 'com.izaodao.gps:id/tvImageSelectGenderMale'
person_gender_female = By.ID, 'com.izaodao.gps:id/tvImageSelectGenderFemale'
person_gender_cancel = By.ID, 'com.izaodao.gps:id/tvImageSelectGenderCancel'
person_username_clear = By.ID, 'com.izaodao.gps:id/ivNameEditClear'
person_username_input = By.ID, 'com.izaodao.gps:id/tvNameEditContent'
person_username_save = By.ID, 'com.izaodao.gps:id/tvNameEditCommit'
person_username_back = By.ID, 'com.izaodao.gps:id/defaultBackButton'
'''
—————————————————————————————————————————————————————————————
登录页面配置信息
_____________________________________________________________
'''
login_otherstyle = By.ID, 'com.izaodao.gps:id/authsdk_switch_view'
login_namepwd = By.XPATH, '//android.view.View[@content-desc="密码登录"]'
login_username = By.XPATH, '//android.widget.EditText[@text = "请输入您的手机/邮箱/用户名"]'
login_password = By.XPATH, '//android.widget.EditText[@text = "请输入密码"]'
login_submit = By.XPATH, '//android.view.View[@content-desc="确定"]'
logIn_back_btn = By.XPATH, '//android.widget.ImageButton'
login_select_frame = By.XPATH, '//android.view.View[@content-desc="登录代表你已阅读并同意"]'
'''
—————————————————————————————————————————————————————————————
任务页面配置信息
_____________________________________________________________
'''
task_coin = By.ID, 'com.izaodao.gps:id/tv_gold'
task_cidao_title_0 = By.ID, 'com.izaodao.gps:id/tv_none_titleW'
task_cidao_title_1 = By.ID, 'com.izaodao.gps:id/tv_already_titleW'
# com.izaodao.gps: id / tv_already_titleW
task_cidao_btn_0 = By.ID, 'com.izaodao.gps:id/tv_none_completeW'
task_cidao_btn_1 = By.ID, 'com.izaodao.gps:id/tv_already_completeW'
task_cidao_download_btn_tanchuang = By.ID, 'com.izaodao.gps:id/tv_apk_install_download_now'
task_share_app_title = By.ID, 'com.izaodao.gps:id/tv_titleA'
task_share_app_btn = By.ID, 'com.izaodao.gps:id/tv_completeA'
task_share_app_to_QQ = By.ID, 'com.izaodao.gps:id/tvShareDialogQQ'
task_ceshi_title = By.ID, 'com.izaodao.gps:id/tv_titleB'
task_ceshi_btn = By.ID, 'com.izaodao.gps:id/tv_completeB'
task_ceshi_score_title = By.ID, 'com.izaodao.gps:id/tv_titleC'
task_ceshi_score_btn = By.ID, 'com.izaodao.gps:id/tv_completeC'
task_go_shop_btn = By.ID, 'com.izaodao.gps:id/tv_start_mall'
task_back_btn = By.ID, 'com.izaodao.gps:id/iv_back'
task_ask_right = By.ID, 'com.android.permissioncontroller:id/permission_allow_button'
task_share_report_to_QQ = By.ID, 'com.izaodao.gps:id/iv_share_qq'
task_tishen_switch = By.ID, 'com.izaodao.gps:id/clMeCidaoDownload'
'''
—————————————————————————————————————————————————————————————
任务页面配置信息
_____________________________________________________________
'''
shop_title = By.ID, 'com.izaodao.gps:id/defaultTitleView'
shop_my_coin = By.XPATH, '//android.view.View[contains(@content-desc ,"我的早金币")]'

'''
—————————————————————————————————————————————————————————————
学习管理页面配置信息
_____________________________________________________________
'''
studymanage_my_course = By.ID, 'com.izaodao.gps:id/tvStudyManageLesson'
studymanage_my_collection = By.ID, 'com.izaodao.gps:id/tvStudyManageFavorite'
studymanage_pronounce = By.ID, 'com.izaodao.gps:id/tvStudyManagePronounce'
studymanage_download = By.ID, 'com.izaodao.gps:id/tvStudyManageVideoDownload'
studymanage_pronounce_3ci = By.XPATH, "//android.widget.TextView[@text = '3次']"
studymanage_my_course_none = By.XPATH, "//android.view.View[@text = '尚未报名任何课程']"
studymanage_my_course1 = By.XPATH, "//android.view.View[contains(@text, '日常用语') ]"
studymanage_my_course_confirm = By.XPATH, "//android.view.View[@text = '开始学习' ]"
studymanage_get_course1 = By.XPATH, "//android.widget.TextView[contains(@text,'初学者要掌握的日常用语')]/../android.widget.TextView[3]"
studymanage_get_course1_close_tanchuang = By.ID, 'com.izaodao.gps:id/iv_close'
studymanage_download1 = By.XPATH, "//android.widget.TextView[@text = '日文构成']"
studymanage_my_collection_empty = By.XPATH, "//android.widget.TextView[@text = '当前无数据']"

'''
—————————————————————————————————————————————————————————————
发现页面配置信息
_____________________________________________________________
'''
discovery_tab = By.ID, 'com.izaodao.gps:id/clMainTabDiscover'
discovery_card_content = By.ID, 'com.izaodao.gps:id/rvDiscoveryTypeCardContent'
discovery_card_content_1 = By.XPATH, "//android.support.v7.widget.RecyclerView[@resource-id='com.izaodao.gps:id/rvDiscoveryTypeCardContent']" \
                                     "/android.widget.RelativeLayout[1]"
discovery_card_content_1_title = By.XPATH, "//android.support.v7.widget.RecyclerView[@resource-id='com.izaodao.gps:id/rvDiscoveryTypeCardContent']" \
                                           "/android.widget.RelativeLayout[1]/android.widget.TextView"
discovery_card_content_1_collect_btn = By.ID, 'com.izaodao.gps:id/ivArticleDetailFavorite'
discovery_card_content_1_share_btn = By.ID, 'com.izaodao.gps:id/ivArticleDetailShare'
discovery_card_content_1_share_qq = By.ID, 'com.izaodao.gps:id/tvShareDialogQQ'
discovery_card_content_1_share_permission = By.ID, "com.android.permissioncontroller:id/permission_allow_button"
discovery_card_content_1_slip_area = By.ID, 'android:id/content'
discovery_card_content_1_dianzan = By.XPATH, "//*[contains(@text, '点赞')][1]"
discovery_card_swipe_area = By.ID, 'com.izaodao.gps:id/clArticleDetailCoordinator'
discovery_banner_assert = By.XPATH, "//*[contains(@text ,'福利领取')]"
discovery_ad_1 = By.ID, 'com.izaodao.gps:id/img_banner'
discovery_ad_1_assert = By.XPATH, "//*[@text ='日语课程免费领取']"
discovery_ad_2 = By.XPATH, "//*[@text = '假名壁纸']/../../android.widget.LinearLayout[1]"
discovery_ad_2_assert = By.XPATH, '//*[@text = "0元学任意一门小语种"]'
discovery_ad_3 = By.XPATH, "//*[@text = '假名壁纸']/../../android.widget.LinearLayout[2]"
discovery_ad_3_assert = By.XPATH, "//*[contains(@text ,'免费领取')]"
discovery_ad_swipe_area = By.ID, "com.izaodao.gps:id/rvDiscoveryList"
discovery_ai_adj = By.ID, 'com.izaodao.gps:id/ai_bookid_1'
discovery_ai_adj_assert = By.XPATH, "//*[@text = '美味しい']"
discovery_ai_addr = By.ID, 'com.izaodao.gps:id/ai_bookid_4'
discovery_ai_addr_assert = By.XPATH, "//*[@text = '美術館']"
discovery_ai_swipe_area = By.ID, 'com.izaodao.gps:id/overlap_pager'
discovery_audio = By.XPATH, "//android.support.v7.widget.RecyclerView" \
                            "[@resource-id = 'com.izaodao.gps:id/rvDiscoveryTypeGridContent']/android.widget.LinearLayout[1]"
discovery_audio_play = By.ID, 'com.izaodao.gps:id/ivAudioPlayerPlay'
discovery_audio_current_time = By.ID, 'com.izaodao.gps:id/tvAudioPlayerCurrentTime'

'''
—————————————————————————————————————————————————————————————
消息推送通知页面
_____________________________________________________________
'''
app_tanchuang_tongzhi = By.ID, 'com.izaodao.gps:id/switch_button'
'''
—————————————————————————————————————————————————————————————
清理缓存
_____________________________________________________________
'''
ql_huancun = By.ID, 'com.izaodao.gps:id/tvSettingClearCacheTitle'
ql_huancun_0b = By.ID, 'com.izaodao.gps:id/tvSettingClearCacheSize'
'''
—————————————————————————————————————————————————————————————
账号安全
_____________________________________________________________
'''
zh_anquan = By.ID, 'com.izaodao.gps:id/tvSettingSecurity'
sq_zhuxiao_zhanghao = By.ID, 'com.izaodao.gps:id/tvSettingMeiqia'
zd_wangxiao = By.ID, 'com.izaodao.gps:id/title_tv'
zh_anquan_if_success = MobileBy.ACCESSIBILITY_ID, '注销后您将放弃以下权益'
'''
—————————————————————————————————————————————————————————————
关于五十音图页面配置信息
_____________________________________________________________
'''
about_zaodao = By.ID, 'com.izaodao.gps:id/tvAboutAppUs'
about_zaodao_title = By.ID, 'com.izaodao.gps:id/defaultTitleView'
about_tel = By.XPATH, "//*[contains(@text,'投诉举报电话')]"
